package models

import(
	// "github.com/astaxie/beego/logs"
	"os"
	"github.com/jinzhu/gorm"
	//_ "github.com/jinzhu/gorm/dialects/mysql"
	_ "github.com/jinzhu/gorm/dialects/sqlite"
)
var (
	db *gorm.DB
)
func init()  {
	// logs.Info("jjjjjj")
	
	err := os.MkdirAll("date",0777) 
	if err != nil {
		panic("failed to connect database:" + err.Error())
	}
	//打开数据库，并复制给db变量，data/data.db数据文件路径
    db, err = gorm.Open("sqlite3", "data.db")
   //存在错误，则程序退出，panic是类似于java的RuntimeException错误
    if err != nil {
        panic("failed to connect database," + err.Error())
    }
  
	
}